home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
Acere (PowerPlant, Game) 1.2
/
AcereÄ.sit
/
Acereƒ
/
Code
/
WellDeck.cp
< prev
next >
Wrap
Text File
|
1995-02-16
|
4KB
|
159 lines
// ===========================================================================
// WellDeck.cp ⌐1993 Metrowerks Inc. All rights reserved.
// ===========================================================================
//
// Class for an object that can draw itself and respond to mouse clicks
#ifdef PowerPlant_PCH
#include PowerPlant_PCH
#endif
#include "WellDeck.h"
#include "CardDeck.h"
#include "AcereApp.h"
#include "CTextDoc.h"
#include <LDynamicArray.h>
#include <LView.h>
#include <LStream.h>
#include <PP_Messages.h>
#include <UDrawingState.h>
extern CTextDoc *theDoc;
extern unsigned long ourAvailRam;
// ---------------------------------------------------------------------------
// Ñ CreatePaneStream [static]
// ---------------------------------------------------------------------------
// Return a new Pane object initialized using data from a Stream
WellDeck*
WellDeck::CreateWellDeck(
LStream *inStream)
{
return (new WellDeck(inStream));
}
// ---------------------------------------------------------------------------
// Ñ WellDeck()
// ---------------------------------------------------------------------------
// Default Constructor
WellDeck::WellDeck() : CardWell()
{
InitCard();
}
// ---------------------------------------------------------------------------
// Ñ WellDeck(const WellDeck&)
// ---------------------------------------------------------------------------
// Copy Constructor
WellDeck::WellDeck(
const WellDeck &inOriginal) : CardWell(inOriginal)
{
// Copy members of Original
InitCard();
}
// ---------------------------------------------------------------------------
// Ñ WellDeck(SPaneInfo&)
// ---------------------------------------------------------------------------
// Construct Pane from data in a struct
WellDeck::WellDeck(const SPaneInfo &inPaneInfo) : CardWell(inPaneInfo)
{
InitCard();
}
// ---------------------------------------------------------------------------
// Ñ WellDeck(LStream*)
// ---------------------------------------------------------------------------
// Construct Pane from data in a Stream
WellDeck::WellDeck(
LStream *inStream) : CardWell(inStream)
{
InitCard();
}
// ---------------------------------------------------------------------------
// Ñ InitPane
// ---------------------------------------------------------------------------
// Initialize Pane from data in a struct
void
WellDeck::InitCard(void)
{
// CardWell::InitPane(inPaneInfo);
theDoc->theDeckWells[theDoc->currentDeckWell] = this;
theDoc->currentDeckWell++;
// itsCard = nil;
}
// ---------------------------------------------------------------------------
// Ñ ~WellDeck
// ---------------------------------------------------------------------------
// Destructor
WellDeck::~WellDeck()
{
PutInside(nil);
if (sLastPaneClicked == this) {
sLastPaneClicked = nil;
}
}
Boolean WellDeck::CanDropOnEmptySlot(PlayingCard *draggedCard)
{
// this will be overridden by most subclasses, which is why it's separate
// default behavior is that ANY card can be dropped on an empty slot
if (draggedCard->card == 1) // it's an ACE
return (true);
else
return (false);
}
Boolean WellDeck::CanDropOnSlot(PlayingCard *draggedCard)
{
// this will be overridden by most subclasses.
// default behavior is that any card can be dropped on any card.
if ((draggedCard->suit == itsCard->suit) &&
(draggedCard->card == (itsCard->card +1)))
return (true);
else
return (false);
}
Boolean WellDeck::CanRemove(void) // can we remove cards from this pile?
{
return (false);
}
void WellDeck::AddCardToWell(CardWell *whichWell, PlayingCard *whichCard)
{
CardWell *itsOwner = whichCard->itsOwner;
PlayingCard *oldCard = itsCard;
CardWell::AddCardToWell(whichWell, whichCard);
if (oldCard != nil)
delete oldCard; // fixes memory leak from cards "disappearing"
itsOwner->DrawSelf();
if (whichCard->card == 13) // it's a King
theDoc->CheckVictory();
}